package com.xzy.a;

import com.xzy.service.SchoolService;
import com.xzy.service.impl.SchoolServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * BeanPostProcessor功能的简单验证
 *
 * @author xzy
 * @date 2021/12/314:31
 */
public class Main {

    public static void main(String[] args) {
        method2();
    }

    private static void method1() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();

        // 注册后置处理器、其他Bean
        applicationContext.register(MyBeanPostProcessor.class);
        applicationContext.register(SchoolServiceImpl.class);
        applicationContext.refresh();

        SchoolService bean = applicationContext.getBean(SchoolService.class);
        System.out.println(bean);
    }

    private static void method2() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();

        // 注册后置处理器、其他Bean
        applicationContext.register(MyInitWareBeanPostProcessor.class);
        applicationContext.register(SchoolServiceImpl.class);
        applicationContext.refresh();

        SchoolService bean = applicationContext.getBean(SchoolService.class);
        System.out.println(bean);
    }
}
